﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using TakeoutMangesBLL;
using Model;

namespace TakeoutMangesWeb
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = txtname.Value.Trim();
            string pwd = txtpwd.Value.Trim();
            Model.UserInfo u = UserInfoBLL.GetUserinfo(name, pwd);
            if (u != null)
            {
                Models.Usersession Usersession = new Models.Usersession()
                {
                    UserID = u.UserID,
                    UserName = u.UserName
                };
                Session["Usersession"] = Usersession;
                //Response.Write("<script>alert('登录成功');window.location.href='shopinfo.aspx';</script>");
                Response.Redirect("shopinfo.aspx");
            }
            else
            {
                Response.Write("<script>alert('请输入正确的用户名或密码');</script>");
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("Register.aspx");
        }
        protected void Button3_Click1(object sender, EventArgs e)
        {
            Response.Redirect("AdminLogin.aspx");
        }
    }
}